/*
 * Author: zhanghj
 * Date: 2020-08-13 15:09:36
 * LastEditors: 黄荣基
 * LastEditTime: 2020-11-20 15:16:57
 */

// 声明path、resolve变量，设置别名所需
const resolve = dir => {
  return require('path').join(__dirname, dir);
};

module.exports = {
  pluginOptions: {
    i18n: {
      locale: 'en',
      fallbackLocale: 'zh',
      localeDir: 'lang',
      enableInSFC: true
    }
  },
  chainWebpack: config => {
    // 修复HMR
    config.resolve.symlinks(true);
  },
  devServer: {
    port: 9090,
    open: true,
    proxy: {
      '/api': {
        target: 'https://unidemo.dcloud.net.cn',
        changeOrigin: true,
        pathRewrite: { '^/api': '/api' }
      }
    }
  },
  chainWebpack: config => {
    // // 设置标签页title
    // config.plugin("html").tap(args => {
    //   args[0].title = "vue-base-tpl"
    //   return args
    // })
    // 设置别名
    config.resolve.alias
      .set('@', resolve('src'))
      .set('img', resolve('src/assets/images'))
      .set('css', resolve('src/assets/css'))
      .set('components', resolve('src/components'));
  }
};
